﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="detailandmedv2_yldandmed", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(Detailandmedv2Yldandmed))]
    public class Detailandmedv2YldandmedSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IDetailandmedv2Yldandmed clazz;
        
        public Detailandmedv2YldandmedSerializer(IDetailandmedv2Yldandmed clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.EttevotteregistriNr!=null) {
                Writer.WriteStartElement("ettevotteregistri_nr");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.EttevotteregistriNr))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.EsmaregistreerimiseKpv!=null) {
                Writer.WriteStartElement("esmaregistreerimise_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.EsmaregistreerimiseKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KustutamiseKpv!=null) {
                Writer.WriteStartElement("kustutamise_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.KustutamiseKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Staatus!=null) {
                Writer.WriteStartElement("staatus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Staatus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.StaatusTekstina!=null) {
                Writer.WriteStartElement("staatus_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.StaatusTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Tegutseb!=null) {
                Writer.WriteStartElement("tegutseb");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Tegutseb))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TegutsebTekstina!=null) {
                Writer.WriteStartElement("tegutseb_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.TegutsebTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MkrRegKpv!=null) {
                Writer.WriteStartElement("mkr_reg_kpv");
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmedv2_mkrreg_kuupaev", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.MkrRegKpv.Count);
                for (int x = 0; ((clazz.MkrRegKpv != null) 
                            && (x < clazz.MkrRegKpv.Count)); x = (x + 1)) {
                    if (clazz.MkrRegKpv[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaMkrRegKpv = this.GetMetaData(clazz.MkrRegKpv[x]);
                        Writer.WriteTypeAttribute(metaMkrRegKpv.TypeQualifiedName.Namespace, metaMkrRegKpv.TypeQualifiedName.Name);
                        metaMkrRegKpv.NewSerializer(clazz.MkrRegKpv[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
                Writer.WriteEndElement();
            }
            if (clazz.EttevotjaTegevuseAeg!=null) {
                Writer.WriteStartElement("ettevotja_tegevuse_aeg");
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmedv2_teg_aeg", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.EttevotjaTegevuseAeg.Count);
                for (int x = 0; ((clazz.EttevotjaTegevuseAeg != null) 
                            && (x < clazz.EttevotjaTegevuseAeg.Count)); x = (x + 1)) {
                    if (clazz.EttevotjaTegevuseAeg[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaEttevotjaTegevuseAeg = this.GetMetaData(clazz.EttevotjaTegevuseAeg[x]);
                        Writer.WriteTypeAttribute(metaEttevotjaTegevuseAeg.TypeQualifiedName.Namespace, metaEttevotjaTegevuseAeg.TypeQualifiedName.Name);
                        metaEttevotjaTegevuseAeg.NewSerializer(clazz.EttevotjaTegevuseAeg[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
                Writer.WriteEndElement();
            }
            if (clazz.EvksRegistreeritud!=null) {
                Writer.WriteStartElement("evks_registreeritud");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.EvksRegistreeritud))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.EvksRegistreeritudKandeKpv!=null) {
                Writer.WriteStartElement("evks_registreeritud_kande_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.EvksRegistreeritudKandeKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OiguslikVorm!=null) {
                Writer.WriteStartElement("oiguslik_vorm");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OiguslikVorm))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OiguslikVormTekstina!=null) {
                Writer.WriteStartElement("oiguslik_vorm_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OiguslikVormTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OiguslikuVormiAlaliik!=null) {
                Writer.WriteStartElement("oigusliku_vormi_alaliik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OiguslikuVormiAlaliik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OiguslikuVormiAlaliikTekstina!=null) {
                Writer.WriteStartElement("oigusliku_vormi_alaliik_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OiguslikuVormiAlaliikTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Sundlopetamine!=null) {
                Writer.WriteStartElement("sundlopetamine");
                global::Xtee.Core.SerializationMetadata metaSundlopetamine = this.GetMetaData(clazz.Sundlopetamine);
                Writer.WriteTypeAttribute(metaSundlopetamine.TypeQualifiedName.Namespace, metaSundlopetamine.TypeQualifiedName.Name);
                metaSundlopetamine.NewSerializer(clazz.Sundlopetamine).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("staatused");
            if (clazz.Staatused!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_staatus", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Staatused.Count);
                for (int x = 0; ((clazz.Staatused != null) 
                            && (x < clazz.Staatused.Count)); x = (x + 1)) {
                    if (clazz.Staatused[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaStaatused = this.GetMetaData(clazz.Staatused[x]);
                        Writer.WriteTypeAttribute(metaStaatused.TypeQualifiedName.Namespace, metaStaatused.TypeQualifiedName.Name);
                        metaStaatused.NewSerializer(clazz.Staatused[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Staatused");
            }
            Writer.WriteEndElement();
            if (clazz.ValismaaAriyhing!=null) {
                Writer.WriteStartElement("valismaa_ariyhing");
                global::Xtee.Core.SerializationMetadata metaValismaaAriyhing = this.GetMetaData(clazz.ValismaaAriyhing);
                Writer.WriteTypeAttribute(metaValismaaAriyhing.TypeQualifiedName.Namespace, metaValismaaAriyhing.TypeQualifiedName.Name);
                metaValismaaAriyhing.NewSerializer(clazz.ValismaaAriyhing).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("arinimed");
            if (clazz.Arinimed!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_arinimi", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Arinimed.Count);
                for (int x = 0; ((clazz.Arinimed != null) 
                            && (x < clazz.Arinimed.Count)); x = (x + 1)) {
                    if (clazz.Arinimed[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaArinimed = this.GetMetaData(clazz.Arinimed[x]);
                        Writer.WriteTypeAttribute(metaArinimed.TypeQualifiedName.Namespace, metaArinimed.TypeQualifiedName.Name);
                        metaArinimed.NewSerializer(clazz.Arinimed[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Arinimed");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("aadressid");
            if (clazz.Aadressid!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_aadress", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Aadressid.Count);
                for (int x = 0; ((clazz.Aadressid != null) 
                            && (x < clazz.Aadressid.Count)); x = (x + 1)) {
                    if (clazz.Aadressid[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaAadressid = this.GetMetaData(clazz.Aadressid[x]);
                        Writer.WriteTypeAttribute(metaAadressid.TypeQualifiedName.Namespace, metaAadressid.TypeQualifiedName.Name);
                        metaAadressid.NewSerializer(clazz.Aadressid[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Aadressid");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("kinnisasjad");
            if (clazz.Kinnisasjad!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_kinnisasi", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Kinnisasjad.Count);
                for (int x = 0; ((clazz.Kinnisasjad != null) 
                            && (x < clazz.Kinnisasjad.Count)); x = (x + 1)) {
                    if (clazz.Kinnisasjad[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaKinnisasjad = this.GetMetaData(clazz.Kinnisasjad[x]);
                        Writer.WriteTypeAttribute(metaKinnisasjad.TypeQualifiedName.Namespace, metaKinnisasjad.TypeQualifiedName.Name);
                        metaKinnisasjad.NewSerializer(clazz.Kinnisasjad[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Kinnisasjad");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("oiguslikud_vormid");
            if (clazz.OiguslikudVormid!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_oiguslik_vorm", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.OiguslikudVormid.Count);
                for (int x = 0; ((clazz.OiguslikudVormid != null) 
                            && (x < clazz.OiguslikudVormid.Count)); x = (x + 1)) {
                    if (clazz.OiguslikudVormid[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaOiguslikudVormid = this.GetMetaData(clazz.OiguslikudVormid[x]);
                        Writer.WriteTypeAttribute(metaOiguslikudVormid.TypeQualifiedName.Namespace, metaOiguslikudVormid.TypeQualifiedName.Name);
                        metaOiguslikudVormid.NewSerializer(clazz.OiguslikudVormid[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OiguslikudVormid");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("oigusliku_vormi_alaliigid");
            if (clazz.OiguslikuVormiAlaliigid!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_oigusliku_vormi_alaliik", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.OiguslikuVormiAlaliigid.Count);
                for (int x = 0; ((clazz.OiguslikuVormiAlaliigid != null) 
                            && (x < clazz.OiguslikuVormiAlaliigid.Count)); x = (x + 1)) {
                    if (clazz.OiguslikuVormiAlaliigid[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaOiguslikuVormiAlaliigid = this.GetMetaData(clazz.OiguslikuVormiAlaliigid[x]);
                        Writer.WriteTypeAttribute(metaOiguslikuVormiAlaliigid.TypeQualifiedName.Namespace, metaOiguslikuVormiAlaliigid.TypeQualifiedName.Name);
                        metaOiguslikuVormiAlaliigid.NewSerializer(clazz.OiguslikuVormiAlaliigid[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OiguslikuVormiAlaliigid");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("kapitalid");
            if (clazz.Kapitalid!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_kapital", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Kapitalid.Count);
                for (int x = 0; ((clazz.Kapitalid != null) 
                            && (x < clazz.Kapitalid.Count)); x = (x + 1)) {
                    if (clazz.Kapitalid[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaKapitalid = this.GetMetaData(clazz.Kapitalid[x]);
                        Writer.WriteTypeAttribute(metaKapitalid.TypeQualifiedName.Namespace, metaKapitalid.TypeQualifiedName.Name);
                        metaKapitalid.NewSerializer(clazz.Kapitalid[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Kapitalid");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("oigusjargsused");
            if (clazz.Oigusjargsused!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_oigusjargsus", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Oigusjargsused.Count);
                for (int x = 0; ((clazz.Oigusjargsused != null) 
                            && (x < clazz.Oigusjargsused.Count)); x = (x + 1)) {
                    if (clazz.Oigusjargsused[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaOigusjargsused = this.GetMetaData(clazz.Oigusjargsused[x]);
                        Writer.WriteTypeAttribute(metaOigusjargsused.TypeQualifiedName.Namespace, metaOigusjargsused.TypeQualifiedName.Name);
                        metaOigusjargsused.NewSerializer(clazz.Oigusjargsused[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Oigusjargsused");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("seisundi_muutused");
            if (clazz.SeisundiMuutused!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_seisundi_muutus", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.SeisundiMuutused.Count);
                for (int x = 0; ((clazz.SeisundiMuutused != null) 
                            && (x < clazz.SeisundiMuutused.Count)); x = (x + 1)) {
                    if (clazz.SeisundiMuutused[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaSeisundiMuutused = this.GetMetaData(clazz.SeisundiMuutused[x]);
                        Writer.WriteTypeAttribute(metaSeisundiMuutused.TypeQualifiedName.Namespace, metaSeisundiMuutused.TypeQualifiedName.Name);
                        metaSeisundiMuutused.NewSerializer(clazz.SeisundiMuutused[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : SeisundiMuutused");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("majandusaastad");
            if (clazz.Majandusaastad!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_majandusaasta", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Majandusaastad.Count);
                for (int x = 0; ((clazz.Majandusaastad != null) 
                            && (x < clazz.Majandusaastad.Count)); x = (x + 1)) {
                    if (clazz.Majandusaastad[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaMajandusaastad = this.GetMetaData(clazz.Majandusaastad[x]);
                        Writer.WriteTypeAttribute(metaMajandusaastad.TypeQualifiedName.Namespace, metaMajandusaastad.TypeQualifiedName.Name);
                        metaMajandusaastad.NewSerializer(clazz.Majandusaastad[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Majandusaastad");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pohikirjad");
            if (clazz.Pohikirjad!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_pohikiri", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Pohikirjad.Count);
                for (int x = 0; ((clazz.Pohikirjad != null) 
                            && (x < clazz.Pohikirjad.Count)); x = (x + 1)) {
                    if (clazz.Pohikirjad[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaPohikirjad = this.GetMetaData(clazz.Pohikirjad[x]);
                        Writer.WriteTypeAttribute(metaPohikirjad.TypeQualifiedName.Namespace, metaPohikirjad.TypeQualifiedName.Name);
                        metaPohikirjad.NewSerializer(clazz.Pohikirjad[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Pohikirjad");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("kompromissi_tahtajad");
            if (clazz.KompromissiTahtajad!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_kompromissi_tahtaeg", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.KompromissiTahtajad.Count);
                for (int x = 0; ((clazz.KompromissiTahtajad != null) 
                            && (x < clazz.KompromissiTahtajad.Count)); x = (x + 1)) {
                    if (clazz.KompromissiTahtajad[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaKompromissiTahtajad = this.GetMetaData(clazz.KompromissiTahtajad[x]);
                        Writer.WriteTypeAttribute(metaKompromissiTahtajad.TypeQualifiedName.Namespace, metaKompromissiTahtajad.TypeQualifiedName.Name);
                        metaKompromissiTahtajad.NewSerializer(clazz.KompromissiTahtajad[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : KompromissiTahtajad");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("asutamise_ajad");
            if (clazz.AsutamiseAjad!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_asutamise_aeg", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.AsutamiseAjad.Count);
                for (int x = 0; ((clazz.AsutamiseAjad != null) 
                            && (x < clazz.AsutamiseAjad.Count)); x = (x + 1)) {
                    if (clazz.AsutamiseAjad[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaAsutamiseAjad = this.GetMetaData(clazz.AsutamiseAjad[x]);
                        Writer.WriteTypeAttribute(metaAsutamiseAjad.TypeQualifiedName.Namespace, metaAsutamiseAjad.TypeQualifiedName.Name);
                        metaAsutamiseAjad.NewSerializer(clazz.AsutamiseAjad[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : AsutamiseAjad");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("tegutsemise_tahtajad");
            if (clazz.TegutsemiseTahtajad!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_tegutsemise_tahtaeg", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.TegutsemiseTahtajad.Count);
                for (int x = 0; ((clazz.TegutsemiseTahtajad != null) 
                            && (x < clazz.TegutsemiseTahtajad.Count)); x = (x + 1)) {
                    if (clazz.TegutsemiseTahtajad[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaTegutsemiseTahtajad = this.GetMetaData(clazz.TegutsemiseTahtajad[x]);
                        Writer.WriteTypeAttribute(metaTegutsemiseTahtajad.TypeQualifiedName.Namespace, metaTegutsemiseTahtajad.TypeQualifiedName.Name);
                        metaTegutsemiseTahtajad.NewSerializer(clazz.TegutsemiseTahtajad[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : TegutsemiseTahtajad");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("esmanimetamise_ajad");
            if (clazz.EsmanimetamiseAjad!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_esmanimetamise_aeg", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.EsmanimetamiseAjad.Count);
                for (int x = 0; ((clazz.EsmanimetamiseAjad != null) 
                            && (x < clazz.EsmanimetamiseAjad.Count)); x = (x + 1)) {
                    if (clazz.EsmanimetamiseAjad[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaEsmanimetamiseAjad = this.GetMetaData(clazz.EsmanimetamiseAjad[x]);
                        Writer.WriteTypeAttribute(metaEsmanimetamiseAjad.TypeQualifiedName.Namespace, metaEsmanimetamiseAjad.TypeQualifiedName.Name);
                        metaEsmanimetamiseAjad.NewSerializer(clazz.EsmanimetamiseAjad[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : EsmanimetamiseAjad");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("markused_kaardil");
            if (clazz.MarkusedKaardil!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_markus_kaardil", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.MarkusedKaardil.Count);
                for (int x = 0; ((clazz.MarkusedKaardil != null) 
                            && (x < clazz.MarkusedKaardil.Count)); x = (x + 1)) {
                    if (clazz.MarkusedKaardil[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaMarkusedKaardil = this.GetMetaData(clazz.MarkusedKaardil[x]);
                        Writer.WriteTypeAttribute(metaMarkusedKaardil.TypeQualifiedName.Namespace, metaMarkusedKaardil.TypeQualifiedName.Name);
                        metaMarkusedKaardil.NewSerializer(clazz.MarkusedKaardil[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : MarkusedKaardil");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("tegevusalad_kaardil");
            if (clazz.TegevusaladKaardil!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_tegevusala_kaardil", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.TegevusaladKaardil.Count);
                for (int x = 0; ((clazz.TegevusaladKaardil != null) 
                            && (x < clazz.TegevusaladKaardil.Count)); x = (x + 1)) {
                    if (clazz.TegevusaladKaardil[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaTegevusaladKaardil = this.GetMetaData(clazz.TegevusaladKaardil[x]);
                        Writer.WriteTypeAttribute(metaTegevusaladKaardil.TypeQualifiedName.Namespace, metaTegevusaladKaardil.TypeQualifiedName.Name);
                        metaTegevusaladKaardil.NewSerializer(clazz.TegevusaladKaardil[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : TegevusaladKaardil");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("eesmargid_kaardil");
            if (clazz.EesmargidKaardil!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_eesmark_kaardil", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.EesmargidKaardil.Count);
                for (int x = 0; ((clazz.EesmargidKaardil != null) 
                            && (x < clazz.EesmargidKaardil.Count)); x = (x + 1)) {
                    if (clazz.EesmargidKaardil[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaEesmargidKaardil = this.GetMetaData(clazz.EesmargidKaardil[x]);
                        Writer.WriteTypeAttribute(metaEesmargidKaardil.TypeQualifiedName.Namespace, metaEesmargidKaardil.TypeQualifiedName.Name);
                        metaEesmargidKaardil.NewSerializer(clazz.EesmargidKaardil[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : EesmargidKaardil");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("sidevahendid");
            if (clazz.Sidevahendid!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_sidevahend", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Sidevahendid.Count);
                for (int x = 0; ((clazz.Sidevahendid != null) 
                            && (x < clazz.Sidevahendid.Count)); x = (x + 1)) {
                    if (clazz.Sidevahendid[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaSidevahendid = this.GetMetaData(clazz.Sidevahendid[x]);
                        Writer.WriteTypeAttribute(metaSidevahendid.TypeQualifiedName.Namespace, metaSidevahendid.TypeQualifiedName.Name);
                        metaSidevahendid.NewSerializer(clazz.Sidevahendid[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Sidevahendid");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("teatatud_tegevusalad");
            if (clazz.TeatatudTegevusalad!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_teatatud_tegevusala", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.TeatatudTegevusalad.Count);
                for (int x = 0; ((clazz.TeatatudTegevusalad != null) 
                            && (x < clazz.TeatatudTegevusalad.Count)); x = (x + 1)) {
                    if (clazz.TeatatudTegevusalad[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaTeatatudTegevusalad = this.GetMetaData(clazz.TeatatudTegevusalad[x]);
                        Writer.WriteTypeAttribute(metaTeatatudTegevusalad.TypeQualifiedName.Namespace, metaTeatatudTegevusalad.TypeQualifiedName.Name);
                        metaTeatatudTegevusalad.NewSerializer(clazz.TeatatudTegevusalad[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : TeatatudTegevusalad");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("info_majandusaasta_aruannetest");
            if (clazz.InfoMajandusaastaAruannetest!=null) {
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("detailandmed_aruande_info", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.InfoMajandusaastaAruannetest.Count);
                for (int x = 0; ((clazz.InfoMajandusaastaAruannetest != null) 
                            && (x < clazz.InfoMajandusaastaAruannetest.Count)); x = (x + 1)) {
                    if (clazz.InfoMajandusaastaAruannetest[x]!=null) {
                        Writer.WriteStartElement("item");
                        global::Xtee.Core.SerializationMetadata metaInfoMajandusaastaAruannetest = this.GetMetaData(clazz.InfoMajandusaastaAruannetest[x]);
                        Writer.WriteTypeAttribute(metaInfoMajandusaastaAruannetest.TypeQualifiedName.Namespace, metaInfoMajandusaastaAruannetest.TypeQualifiedName.Name);
                        metaInfoMajandusaastaAruannetest.NewSerializer(clazz.InfoMajandusaastaAruannetest[x]).WriteXml(Writer);
                        Writer.WriteEndElement();
                    }
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : InfoMajandusaastaAruannetest");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="ettevotteregistri_nr") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>ettevotteregistri_nr");
                }
                clazz.EttevotteregistriNr = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("ettevotteregistri_nr")).Value;
            }
            if (Reader.LocalName=="esmaregistreerimise_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>esmaregistreerimise_kpv");
                }
                clazz.EsmaregistreerimiseKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("esmaregistreerimise_kpv")).Value;
            }
            if (Reader.LocalName=="kustutamise_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>kustutamise_kpv");
                }
                clazz.KustutamiseKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("kustutamise_kpv")).Value;
            }
            if (Reader.LocalName=="staatus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>staatus");
                }
                clazz.Staatus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("staatus")).Value;
            }
            if (Reader.LocalName=="staatus_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>staatus_tekstina");
                }
                clazz.StaatusTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("staatus_tekstina")).Value;
            }
            if (Reader.LocalName=="tegutseb") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>tegutseb");
                }
                clazz.Tegutseb = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tegutseb")).Value;
            }
            if (Reader.LocalName=="tegutseb_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>tegutseb_tekstina");
                }
                clazz.TegutsebTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("tegutseb_tekstina")).Value;
            }
            if (Reader.LocalName=="mkr_reg_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>mkr_reg_kpv");
                }
                clazz.MkrRegKpv = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedv2MkrregKuupaev>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("mkr_reg_kpv");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_mkrreg_kuupaevad>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaMkrRegKpv = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedv2MkrregKuupaev>(Reader, "detailandmedv2_mkrreg_kuupaev", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedv2MkrregKuupaev item = metaMkrRegKpv.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedv2MkrregKuupaev>();
                        clazz.MkrRegKpv.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaMkrRegKpv.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="ettevotja_tegevuse_aeg") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>ettevotja_tegevuse_aeg");
                }
                clazz.EttevotjaTegevuseAeg = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedv2TegAeg>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("ettevotja_tegevuse_aeg");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_teg_ajad>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaEttevotjaTegevuseAeg = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedv2TegAeg>(Reader, "detailandmedv2_teg_aeg", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedv2TegAeg item = metaEttevotjaTegevuseAeg.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedv2TegAeg>();
                        clazz.EttevotjaTegevuseAeg.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaEttevotjaTegevuseAeg.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="evks_registreeritud") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>evks_registreeritud");
                }
                clazz.EvksRegistreeritud = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("evks_registreeritud")).Value;
            }
            if (Reader.LocalName=="evks_registreeritud_kande_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>evks_registreeritud_kande_kpv");
                }
                clazz.EvksRegistreeritudKandeKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("evks_registreeritud_kande_kpv")).Value;
            }
            if (Reader.LocalName=="oiguslik_vorm") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>oiguslik_vorm");
                }
                clazz.OiguslikVorm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oiguslik_vorm")).Value;
            }
            if (Reader.LocalName=="oiguslik_vorm_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>oiguslik_vorm_tekstina");
                }
                clazz.OiguslikVormTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oiguslik_vorm_tekstina")).Value;
            }
            if (Reader.LocalName=="oigusliku_vormi_alaliik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>oigusliku_vormi_alaliik");
                }
                clazz.OiguslikuVormiAlaliik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oigusliku_vormi_alaliik")).Value;
            }
            if (Reader.LocalName=="oigusliku_vormi_alaliik_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>oigusliku_vormi_alaliik_tekstina");
                }
                clazz.OiguslikuVormiAlaliikTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oigusliku_vormi_alaliik_tekstina")).Value;
            }
            if (Reader.LocalName=="sundlopetamine") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>sundlopetamine");
                }
                global::Xtee.Core.SerializationMetadata metaSundlopetamine = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedSundlopetamine>(Reader, "detailandmed_sundlopetamine", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                clazz.Sundlopetamine = metaSundlopetamine.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedSundlopetamine>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("sundlopetamine");
                    metaSundlopetamine.NewSerializer(clazz.Sundlopetamine).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="staatused") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>staatused");
                }
                clazz.Staatused = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedStaatus>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("staatused");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_staatused>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaStaatused = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedStaatus>(Reader, "detailandmed_staatus", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedStaatus item = metaStaatused.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedStaatus>();
                        clazz.Staatused.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaStaatused.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>staatused", Reader.LocalName);
            }
            if (Reader.LocalName=="valismaa_ariyhing") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>valismaa_ariyhing");
                }
                global::Xtee.Core.SerializationMetadata metaValismaaAriyhing = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedValismaaAriyhing>(Reader, "detailandmed_valismaa_ariyhing", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                clazz.ValismaaAriyhing = metaValismaaAriyhing.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedValismaaAriyhing>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("valismaa_ariyhing");
                    metaValismaaAriyhing.NewSerializer(clazz.ValismaaAriyhing).ReadXml(Reader);
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="arinimed") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>arinimed");
                }
                clazz.Arinimed = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedArinimi>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("arinimed");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_arinimed>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaArinimed = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedArinimi>(Reader, "detailandmed_arinimi", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedArinimi item = metaArinimed.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedArinimi>();
                        clazz.Arinimed.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaArinimed.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>arinimed", Reader.LocalName);
            }
            if (Reader.LocalName=="aadressid") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>aadressid");
                }
                clazz.Aadressid = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedAadress>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("aadressid");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_aadressid>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaAadressid = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedAadress>(Reader, "detailandmed_aadress", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedAadress item = metaAadressid.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedAadress>();
                        clazz.Aadressid.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaAadressid.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>aadressid", Reader.LocalName);
            }
            if (Reader.LocalName=="kinnisasjad") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>kinnisasjad");
                }
                clazz.Kinnisasjad = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedKinnisasi>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("kinnisasjad");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kinnisasjad>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaKinnisasjad = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedKinnisasi>(Reader, "detailandmed_kinnisasi", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedKinnisasi item = metaKinnisasjad.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedKinnisasi>();
                        clazz.Kinnisasjad.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaKinnisasjad.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>kinnisasjad", Reader.LocalName);
            }
            if (Reader.LocalName=="oiguslikud_vormid") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>oiguslikud_vormid");
                }
                clazz.OiguslikudVormid = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedOiguslikVorm>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("oiguslikud_vormid");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_oiguslikud_vormid>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaOiguslikudVormid = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedOiguslikVorm>(Reader, "detailandmed_oiguslik_vorm", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedOiguslikVorm item = metaOiguslikudVormid.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedOiguslikVorm>();
                        clazz.OiguslikudVormid.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaOiguslikudVormid.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>oiguslikud_vormid", Reader.LocalName);
            }
            if (Reader.LocalName=="oigusliku_vormi_alaliigid") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>oigusliku_vormi_alaliigid");
                }
                clazz.OiguslikuVormiAlaliigid = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedOiguslikuVormiAlaliik>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("oigusliku_vormi_alaliigid");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_oigusliku_vormi_alaliigid>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaOiguslikuVormiAlaliigid = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedOiguslikuVormiAlaliik>(Reader, "detailandmed_oigusliku_vormi_alaliik", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedOiguslikuVormiAlaliik item = metaOiguslikuVormiAlaliigid.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedOiguslikuVormiAlaliik>();
                        clazz.OiguslikuVormiAlaliigid.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaOiguslikuVormiAlaliigid.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>oigusliku_vormi_alaliigid", Reader.LocalName);
            }
            if (Reader.LocalName=="kapitalid") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>kapitalid");
                }
                clazz.Kapitalid = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedKapital>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("kapitalid");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kapitalid>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaKapitalid = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedKapital>(Reader, "detailandmed_kapital", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedKapital item = metaKapitalid.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedKapital>();
                        clazz.Kapitalid.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaKapitalid.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>kapitalid", Reader.LocalName);
            }
            if (Reader.LocalName=="oigusjargsused") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>oigusjargsused");
                }
                clazz.Oigusjargsused = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedOigusjargsus>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("oigusjargsused");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_oigusjargsused>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaOigusjargsused = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedOigusjargsus>(Reader, "detailandmed_oigusjargsus", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedOigusjargsus item = metaOigusjargsused.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedOigusjargsus>();
                        clazz.Oigusjargsused.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaOigusjargsused.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>oigusjargsused", Reader.LocalName);
            }
            if (Reader.LocalName=="seisundi_muutused") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>seisundi_muutused");
                }
                clazz.SeisundiMuutused = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedSeisundiMuutus>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("seisundi_muutused");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_seisundi_muutused>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaSeisundiMuutused = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedSeisundiMuutus>(Reader, "detailandmed_seisundi_muutus", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedSeisundiMuutus item = metaSeisundiMuutused.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedSeisundiMuutus>();
                        clazz.SeisundiMuutused.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaSeisundiMuutused.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>seisundi_muutused", Reader.LocalName);
            }
            if (Reader.LocalName=="majandusaastad") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>majandusaastad");
                }
                clazz.Majandusaastad = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedMajandusaasta>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("majandusaastad");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_majandusaastad>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaMajandusaastad = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedMajandusaasta>(Reader, "detailandmed_majandusaasta", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedMajandusaasta item = metaMajandusaastad.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedMajandusaasta>();
                        clazz.Majandusaastad.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaMajandusaastad.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>majandusaastad", Reader.LocalName);
            }
            if (Reader.LocalName=="pohikirjad") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>pohikirjad");
                }
                clazz.Pohikirjad = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedPohikiri>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("pohikirjad");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pohikirjad>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaPohikirjad = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedPohikiri>(Reader, "detailandmed_pohikiri", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedPohikiri item = metaPohikirjad.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedPohikiri>();
                        clazz.Pohikirjad.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaPohikirjad.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>pohikirjad", Reader.LocalName);
            }
            if (Reader.LocalName=="kompromissi_tahtajad") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>kompromissi_tahtajad");
                }
                clazz.KompromissiTahtajad = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedKompromissiTahtaeg>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("kompromissi_tahtajad");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_kompromissi_tahtajad>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaKompromissiTahtajad = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedKompromissiTahtaeg>(Reader, "detailandmed_kompromissi_tahtaeg", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedKompromissiTahtaeg item = metaKompromissiTahtajad.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedKompromissiTahtaeg>();
                        clazz.KompromissiTahtajad.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaKompromissiTahtajad.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>kompromissi_tahtajad", Reader.LocalName);
            }
            if (Reader.LocalName=="asutamise_ajad") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>asutamise_ajad");
                }
                clazz.AsutamiseAjad = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedAsutamiseAeg>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("asutamise_ajad");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_asutamise_ajad>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaAsutamiseAjad = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedAsutamiseAeg>(Reader, "detailandmed_asutamise_aeg", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedAsutamiseAeg item = metaAsutamiseAjad.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedAsutamiseAeg>();
                        clazz.AsutamiseAjad.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaAsutamiseAjad.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>asutamise_ajad", Reader.LocalName);
            }
            if (Reader.LocalName=="tegutsemise_tahtajad") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>tegutsemise_tahtajad");
                }
                clazz.TegutsemiseTahtajad = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedTegutsemiseTahtaeg>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("tegutsemise_tahtajad");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_tegutsemise_tahtajad>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaTegutsemiseTahtajad = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedTegutsemiseTahtaeg>(Reader, "detailandmed_tegutsemise_tahtaeg", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedTegutsemiseTahtaeg item = metaTegutsemiseTahtajad.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedTegutsemiseTahtaeg>();
                        clazz.TegutsemiseTahtajad.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaTegutsemiseTahtajad.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>tegutsemise_tahtajad", Reader.LocalName);
            }
            if (Reader.LocalName=="esmanimetamise_ajad") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>esmanimetamise_ajad");
                }
                clazz.EsmanimetamiseAjad = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedEsmanimetamiseAeg>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("esmanimetamise_ajad");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_esmanimetamise_ajad>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaEsmanimetamiseAjad = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedEsmanimetamiseAeg>(Reader, "detailandmed_esmanimetamise_aeg", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedEsmanimetamiseAeg item = metaEsmanimetamiseAjad.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedEsmanimetamiseAeg>();
                        clazz.EsmanimetamiseAjad.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaEsmanimetamiseAjad.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>esmanimetamise_ajad", Reader.LocalName);
            }
            if (Reader.LocalName=="markused_kaardil") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>markused_kaardil");
                }
                clazz.MarkusedKaardil = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedMarkusKaardil>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("markused_kaardil");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_markused_kaardil>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaMarkusedKaardil = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedMarkusKaardil>(Reader, "detailandmed_markus_kaardil", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedMarkusKaardil item = metaMarkusedKaardil.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedMarkusKaardil>();
                        clazz.MarkusedKaardil.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaMarkusedKaardil.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>markused_kaardil", Reader.LocalName);
            }
            if (Reader.LocalName=="tegevusalad_kaardil") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>tegevusalad_kaardil");
                }
                clazz.TegevusaladKaardil = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedTegevusalaKaardil>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("tegevusalad_kaardil");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_tegevusalad_kaardil>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaTegevusaladKaardil = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedTegevusalaKaardil>(Reader, "detailandmed_tegevusala_kaardil", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedTegevusalaKaardil item = metaTegevusaladKaardil.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedTegevusalaKaardil>();
                        clazz.TegevusaladKaardil.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaTegevusaladKaardil.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>tegevusalad_kaardil", Reader.LocalName);
            }
            if (Reader.LocalName=="eesmargid_kaardil") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>eesmargid_kaardil");
                }
                clazz.EesmargidKaardil = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedEesmarkKaardil>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("eesmargid_kaardil");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_eesmargid_kaardil>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaEesmargidKaardil = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedEesmarkKaardil>(Reader, "detailandmed_eesmark_kaardil", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedEesmarkKaardil item = metaEesmargidKaardil.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedEesmarkKaardil>();
                        clazz.EesmargidKaardil.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaEesmargidKaardil.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>eesmargid_kaardil", Reader.LocalName);
            }
            if (Reader.LocalName=="sidevahendid") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>sidevahendid");
                }
                clazz.Sidevahendid = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedSidevahend>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("sidevahendid");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_sidevahendid>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaSidevahendid = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedSidevahend>(Reader, "detailandmed_sidevahend", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedSidevahend item = metaSidevahendid.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedSidevahend>();
                        clazz.Sidevahendid.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaSidevahendid.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>sidevahendid", Reader.LocalName);
            }
            if (Reader.LocalName=="teatatud_tegevusalad") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>teatatud_tegevusalad");
                }
                clazz.TeatatudTegevusalad = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedTeatatudTegevusala>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("teatatud_tegevusalad");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_teatatud_tegevusalad>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaTeatatudTegevusalad = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedTeatatudTegevusala>(Reader, "detailandmed_teatatud_tegevusala", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedTeatatudTegevusala item = metaTeatatudTegevusalad.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedTeatatudTegevusala>();
                        clazz.TeatatudTegevusalad.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaTeatatudTegevusalad.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>teatatud_tegevusalad", Reader.LocalName);
            }
            if (Reader.LocalName=="info_majandusaasta_aruannetest") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmedv2_yldandmed>info_majandusaasta_aruannetest");
                }
                clazz.InfoMajandusaastaAruannetest = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedAruandeInfo>();
                if ((Reader.IsEmptyElement == false)) {
                    Reader.ReadStartElement("info_majandusaasta_aruannetest");
                    for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                && (Reader.LocalName == "item")); ) {
                        if (Reader.IsElementNil()) {
                            throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_aruande_infod>item");
                        }
                        global::Xtee.Core.SerializationMetadata metaInfoMajandusaastaAruannetest = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedAruandeInfo>(Reader, "detailandmed_aruande_info", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedAruandeInfo item = metaInfoMajandusaastaAruannetest.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IDetailandmedAruandeInfo>();
                        clazz.InfoMajandusaastaAruannetest.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaInfoMajandusaastaAruannetest.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    Reader.ReadEndElement();
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>detailandmedv2_yldandmed>info_majandusaasta_aruannetest", Reader.LocalName);
            }
        }
    }
}
